package com.youhome.service.service.impl;

import com.youhome.common.enums.ZilLowSearchTypeEnum;
import com.youhome.common.enums.ZillowTypeEnum;
import com.youhome.common.exception.CustomException;
import com.youhome.service.dto.report.DTOBuyerSeller;
import com.youhome.service.model.ZipCode;
import com.youhome.service.response.*;
import com.youhome.service.service.ReportZilLowService;
import com.youhome.service.service.ZilLowByCityService;
import com.youhome.service.service.ZillowService;
import com.youhome.service.service.ZipCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chen365 on 2019/05/27.
 */
@Service
public class ReportZilLowServiceImpl implements ReportZilLowService {
    @Autowired
    private ZillowService ZillowService;
    @Autowired
    private ZilLowByCityService zilLowByCityService;
    @Autowired
    private ZipCodeService zipCodeService;


    /***
     * 买卖指数 non-time
     * @param model model
     * @param zipCode 邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year 年
     */
    @Override
    public void buyer_seller_index(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            BuyerSellerResult buyer_seller_index_result = new BuyerSellerResult();

            if (dataType.equalsIgnoreCase("zip")) {
                buyer_seller_index_result = ZillowService.get_Buyer_Seller_Index_Zip(ZillowTypeEnum.BuyerSellerIndex_Zip.getKey(), zipCode.getZip());
            } else if (dataType.equalsIgnoreCase("city")) {
                buyer_seller_index_result = zilLowByCityService.get_Buyer_Seller_Index_City(zipCode);
            }

            model.addAttribute("buyer_seller_index_result", buyer_seller_index_result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }


    /***
     * 滑动平均值销售存量 time
     * @param model model
     * @param zipCode 邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year 年
     */
    @Override
    public void inventory_measure_ssa_public(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> inventory_measure_ssa_public = null;

            if (dataType.equalsIgnoreCase("zip")) {
                inventory_measure_ssa_public = ZillowService.getTimeSeries(ZillowTypeEnum.InventoryMeasure_SSA_Zip_Public.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                inventory_measure_ssa_public = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.InventoryMeasure_SSA_City_Public.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }
            model.addAttribute("inventory_measure_ssa_public_result", inventory_measure_ssa_public);

        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    /***
     * 销售存量 time
     * @param model model
     * @param zipCode 邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year 年
     */
    @Override
    public void inventory_measure_public(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> inventory_measure_public_result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                inventory_measure_public_result = ZillowService.getTimeSeries(ZillowTypeEnum.InventoryMeasure_Zip_Public.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                inventory_measure_public_result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.InventoryMeasure_City_Public.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("inventory_measure_public_result", inventory_measure_public_result);

        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    /**
     * 市场健康指数 non-time
     *
     * @param model    model
     * @param zipCode  邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year     年
     */
    @Override
    public void market_health_index(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            MarketHealthResult market_health_index_result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                market_health_index_result = ZillowService.get_Market_Health_Index_Zip(ZillowTypeEnum.MarketHealthIndex_Zip.getKey(), zipCode.getZip());
            } else if (dataType.equalsIgnoreCase("city")) {
                market_health_index_result = zilLowByCityService.get_Market_Health_Index_City(zipCode);
            }

            model.addAttribute("market_health_index_result", market_health_index_result);

        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    /**
     * 降价幅度比例-全部
     *
     * @param model    model
     * @param zipCode  邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year     年
     */
    @Override
    public void listings_price_cut_seas_adj_all_homes(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> listings_price_cut_seas_adj_all_homes_result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                listings_price_cut_seas_adj_all_homes_result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Listings_PriceCut_SeasAdj_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                listings_price_cut_seas_adj_all_homes_result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Listings_PriceCut_SeasAdj_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("listings_price_cut_seas_adj_all_homes_result", listings_price_cut_seas_adj_all_homes_result);

        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    /**
     * 降价幅度比例-公寓 time
     *
     * @param model    model
     * @param zipCode  邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year     年
     */
    @Override
    public void listings_price_cut_seas_adj_condominum(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> listings_price_cut_seas_adj_condominum_result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                listings_price_cut_seas_adj_condominum_result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Listings_PriceCut_SeasAdj_Condominum.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                listings_price_cut_seas_adj_condominum_result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Listings_PriceCut_SeasAdj_Condominum.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("listings_price_cut_seas_adj_condominum_result", listings_price_cut_seas_adj_condominum_result);

        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    /**
     * 降价幅度比例-独栋 time
     *
     * @param model    model
     * @param zipCode  邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year     年
     */
    @Override
    public void listings_price_cut_seas_adj_single_family_residence(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> listings_price_cut_seas_adj_single_family_residence_result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                listings_price_cut_seas_adj_single_family_residence_result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Listings_PriceCut_SeasAdj_SingleFamilyResidence.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                listings_price_cut_seas_adj_single_family_residence_result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Listings_PriceCut_SeasAdj_SingleFamilyResidence.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("listings_price_cut_seas_adj_single_family_residence_result", listings_price_cut_seas_adj_single_family_residence_result);

        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    /**
     * 降价幅度金额-全部	time
     *
     * @param model    model
     * @param zipCode  邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year     年
     */
    @Override
    public void median_price_cut_dollar_all_homes(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> median_price_cut_dollar_all_homes_result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                median_price_cut_dollar_all_homes_result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Median_PriceCut_Dollar_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                median_price_cut_dollar_all_homes_result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Median_PriceCut_Dollar_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_price_cut_dollar_condominum_result", median_price_cut_dollar_all_homes_result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    /**
     * 降价幅度金额-公寓	time
     *
     * @param model    model
     * @param zipCode  邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year     年
     */
    @Override
    public void median_price_cut_dollar_condominum(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Median_PriceCut_Dollar_Condominum.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Median_PriceCut_Dollar_Condominum.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_price_cut_dollar_condominum_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }


    }

    /**
     * 降价幅度金额-独栋	time
     *
     * @param model    model
     * @param zipCode  邮编
     * @param dataType 数据类型 zip,city,state,metro
     * @param year     年
     */
    @Override
    public void median_price_cut_dollar_single_family_residence(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Median_PriceCut_Dollar_SingleFamilyResidence.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Median_PriceCut_Dollar_SingleFamilyResidence.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_price_cut_dollar_single_family_residence_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_listing_price_1bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_1Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_1Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_1bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_2bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_2Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_2Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_2bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_3bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_3Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_3Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_3bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_4bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_4Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_4Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_4bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_5bedroom_or_more(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_5BedroomOrMore.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_5BedroomOrMore.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_5bedroom_or_more_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_all_homes(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_condo_coop(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_CondoCoop.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_CondoCoop.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_condo_coop_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_listing_price_duplex_triplex(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_DuplexTriplex.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_DuplexTriplex.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_duplex_triplex_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_sfr(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_Sfr.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_Sfr.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_sfr_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }


    @Override
    public void median_listing_price_per_sqft_1bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPricePerSqft_1Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPricePerSqft_1Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_1bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_per_sqft_2bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPricePerSqft_2Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPricePerSqft_2Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_2bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_per_sqft_3bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPricePerSqft_3Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPricePerSqft_3Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_3bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_per_sqft_4bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPricePerSqft_4Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPricePerSqft_4Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_4bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_per_sqft_5bedroom_or_more(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_5BedroomOrMore.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_5BedroomOrMore.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_5bedroom_or_more_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_per_sqft_all_homes(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPricePerSqft_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPricePerSqft_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_per_sqft_condo_coop(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;
            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPricePerSqft_CondoCoop.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPricePerSqft_CondoCoop.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_condo_coop_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_listing_price_per_sqft_duplex_triplex(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPricePerSqft_DuplexTriplex.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPricePerSqft_DuplexTriplex.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_duplex_triplex_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_per_sqft_sfr(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPricePerSqft_Sfr.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPricePerSqft_Sfr.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_per_sqft_sfr_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_pct_of_price_reduction_all_homes(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianPctOfPriceReduction_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianPctOfPriceReduction_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_pct_of_price_reduction_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }


    }

    @Override
    public void median_pct_of_price_reduction_condominum(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianPctOfPriceReduction_Condominum.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianPctOfPriceReduction_Condominum.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_pct_of_price_reduction_condominum_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_pct_of_price_reduction_single_family_residence(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianPctOfPriceReduction_SingleFamilyResidence.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianPctOfPriceReduction_SingleFamilyResidence.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_pct_of_price_reduction_single_family_residence_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_rental_price_1bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_1Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_1Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_1bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_2bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_2Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_2Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_2bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_3bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_3Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_3Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_3bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }


    @Override
    public void median_rental_price_4bedroom(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_4Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_4Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_4bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_5bedroom_or_more(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_5BedroomOrMore.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_5BedroomOrMore.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_5bedroom_or_more_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_all_homes(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_all_homes", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_condo_coop(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_CondoCoop.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_CondoCoop.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_condo_coop_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_rental_price_duplex_triplex(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_DuplexTriplex.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_DuplexTriplex.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_duplex_triplex_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_rental_price_mfr_5plus(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_Mfr5Plus.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_Mfr5Plus.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_mfr_5plus_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_rental_price_sfr(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_Sfr.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_Sfr.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_sfr_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_rental_price_studio(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPrice_Studio.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPrice_Studio.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_studio_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void median_rental_price_per_sqft_1bedroom_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_1Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_1Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_1bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_2bedroom_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_2Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_2Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_2bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_3bedroom_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_3Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_3Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_3bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_4bedroom_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_4Bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_4Bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_4bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_5bedroom_or_more_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_5BedroomOrMore.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_5BedroomOrMore.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_5bedroom_or_more_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_condo_coop_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_CondoCoop.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_CondoCoop.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_condo_coop_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_duplex_triplex_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_DuplexTriplex.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_DuplexTriplex.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_duplex_triplex_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_mfr_5plus_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_Mfr5Plus.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_Mfr5Plus.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_mfr_5plus_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_sfr_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_Sfr.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_Sfr.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_sfr_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_rental_price_per_sqft_studio_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianRentalPricePerSqft_Studio.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianRentalPricePerSqft_Studio.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_rental_price_per_sqft_studio_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_value_per_sqft_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianValuePerSqft_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianValuePerSqft_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_value_per_sqft_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void pct_of_homes_decreasing_in_values_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_PctOfHomesDecreasingInValues_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_PctOfHomesDecreasingInValues_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("pct_of_homes_decreasing_in_values_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void pct_of_homes_increasing_in_values_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_PctOfHomesIncreasingInValues_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_PctOfHomesIncreasingInValues_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("pct_of_homes_increasing_in_values_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void pct_of_listings_with_price_reductions_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_PctOfListingsWithPriceReductions_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_PctOfListingsWithPriceReductions_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("pct_of_listings_with_price_reductions_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void pct_of_listings_with_price_reductions_condominum_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_PctOfListingsWithPriceReductions_Condominum.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_PctOfListingsWithPriceReductions_Condominum.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("pct_of_listings_with_price_reductions_condominum_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void pct_of_listings_with_price_reductions_single_family_residence_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_PctOfListingsWithPriceReductions_SingleFamilyResidence.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_PctOfListingsWithPriceReductions_SingleFamilyResidence.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("pct_of_listings_with_price_reductions_single_family_residence_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void price_to_rent_ratio_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_PriceToRentRatio_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_PriceToRentRatio_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("price_to_rent_ratio_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_1bedroom_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_1bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_1bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_1bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_2bedroom_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_2bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_2bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_2bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_3bedroom_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_3bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_3bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_3bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_4bedroom_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_4bedroom.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_4bedroom.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_4bedroom_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_5bedroom_or_more_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_5BedroomOrMore.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_5BedroomOrMore.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_5bedroom_or_more_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_bottom_tier_yoy_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_BottomTier_yoy.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_BottomTier_yoy.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_bottom_tier_yoy_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_bottom_tier_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_BottomTier.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_BottomTier.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_bottom_tier_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_condominum_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_Condominum.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_Condominum.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_condominum_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_middle_tier_yoy_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_MiddleTier_yoy.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_MiddleTier_yoy.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_middle_tier_yoy_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_middle_tier_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_MiddleTier.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_MiddleTier.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_middle_tier_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_single_family_residence_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_SingleFamilyResidence.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_SingleFamilyResidence.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_single_family_residence_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_summary_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            ZhviResult result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.get_Zip_Zhvi_Summary_AllHomes(ZillowTypeEnum.Zip_Zhvi_Summary_AllHomes.getKey(), zipCode.getZip());
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.get_City_Zhvi_Summary_AllHomes(zipCode.getPrimaryCity(), zipCode.getState(), zipCode.getCounty());
            }

            model.addAttribute("zhvi_summary_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_top_tier_yoy_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_TopTier_yoy.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_TopTier_yoy.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_top_tier_yoy_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zhvi_top_tier_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zhvi_TopTier.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zhvi_TopTier.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zhvi_top_tier_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_all_homes_summary_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            ZriResult result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.get_Zip_Zri_AllHomes_Summary(ZillowTypeEnum.Zip_Zri_AllHomes_Summary.getKey(), zipCode.getZip());
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.get_City_Zri_AllHomes_Summary(ZillowTypeEnum.City_Zri_AllHomes_Summary.getKey(), zipCode.getPrimaryCity(), zipCode.getState(), zipCode.getCounty());
            }

            model.addAttribute("zri_all_homes_summary_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zri_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zri_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zri_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_all_homes_plus_multifamily_summary_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            ZriResult result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.get_Zip_Zri_AllHomes_Summary(ZillowTypeEnum.Zip_Zri_AllHomesPlusMultifamily_Summary.getKey(), zipCode.getZip());
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.get_City_Zri_AllHomes_Summary(ZillowTypeEnum.City_Zri_AllHomesPlusMultifamily_Summary.getKey(), zipCode.getPrimaryCity(), zipCode.getState(), zipCode.getCounty());
            }

            model.addAttribute("zri_all_homes_plus_multifamily_summary_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_all_homes_plus_multifamily_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zri_AllHomesPlusMultifamily.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zri_AllHomesPlusMultifamily.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zri_all_homes_plus_multifamily_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_multifamily_residence_rental_summary_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            ZriResult result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.get_Zip_Zri_AllHomes_Summary(ZillowTypeEnum.Zip_Zri_MultiFamilyResidenceRental_Summary.getKey(), zipCode.getZip());
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.get_City_Zri_AllHomes_Summary(ZillowTypeEnum.City_Zri_MultiFamilyResidenceRental_Summary.getKey(), zipCode.getPrimaryCity(), zipCode.getState(), zipCode.getCounty());
            }

            model.addAttribute("zri_multifamily_residence_rental_summary_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_multifamily_residence_rental_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zri_MultiFamilyResidenceRental.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zri_MultiFamilyResidenceRental.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zri_multifamily_residence_rental_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_single_family_residence_rental_summary_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            ZriResult result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.get_Zip_Zri_AllHomes_Summary(ZillowTypeEnum.Zip_Zri_SingleFamilyResidenceRental_Summary.getKey(), zipCode.getZip());
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.get_City_Zri_AllHomes_Summary(ZillowTypeEnum.City_Zri_SingleFamilyResidenceRental_Summary.getKey(), zipCode.getPrimaryCity(), zipCode.getState(), zipCode.getCounty());
            }

            model.addAttribute("zri_single_family_residence_rental_summary_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_single_family_residence_rental_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_Zri_SingleFamilyResidenceRental.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_Zri_SingleFamilyResidenceRental.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zri_single_family_residence_rental_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_per_sqft_all_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_ZriPerSqft_AllHomes.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_ZriPerSqft_AllHomes.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("zri_per_sqft_all_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void breakeven_pr_result(Model model, ZipCode zipCode, String dataType, Integer year) {

            BreakEvenPRResult result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.get_Break_Even_PR(ZillowTypeEnum.BreakEven_PR.getKey(), zipCode.getZip());
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.get_Break_Even_PR(ZillowTypeEnum.BreakEven_PR.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("breakeven_pr_result", result);
    }

    @Override
    public void mortgage_affordability_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = ZillowService.getTimeSeries(ZillowTypeEnum.Affordability_Wide_Public_Loan.getKey(), zipCode.getZip(), year);;
            model.addAttribute("mortgage_affordability_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void price_to_income_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = ZillowService.getTimeSeries(ZillowTypeEnum.Affordability_Wide_Public_Ratio.getKey(), zipCode.getZip(), year);;
            model.addAttribute("price_to_income_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void rent_affordability_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = ZillowService.getTimeSeries(ZillowTypeEnum.Affordability_Wide_Public_Rent.getKey(), zipCode.getZip(), year);;
            model.addAttribute("rent_affordability_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void zri_forecast_public_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            ZriForecastPublicResult zri_forecast_public = ZillowService.get_Zri_Forecast_Public(ZillowTypeEnum.ZriForecast_Public.getKey(), zipCode.getZip());
            model.addAttribute("zri_forecast_public_result", zri_forecast_public);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void sale_to_list_ratio_city_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> sale_to_list_ratio_city_result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.SaleToListRatio_City.getKey(), zipCode.getZip(), year);
            model.addAttribute("sale_to_list_ratio_city_result", sale_to_list_ratio_city_result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void days_on_market_city_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> days_on_market_city_result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.DaysOnZillow_City.getKey(), zipCode.getZip(), year);
            model.addAttribute("days_on_market_city_result", days_on_market_city_result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_bottom_tier_result(Model model, ZipCode zipCode, String dataType, Integer year) {

        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_BottomTier.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_BottomTier.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_bottom_tier_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void median_listing_price_top_tier_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Zip_MedianListingPrice_TopTier.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.City_MedianListingPrice_TopTier.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("median_listing_price_top_tier_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void sale_counts_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Sale_Counts_Zip.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.Sale_Counts_City.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("sale_counts_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void sale_counts_seas_adj_city_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Sale_Counts_Seas_Adj_City.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.Sale_Counts_Seas_Adj_City.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("sale_counts_seas_adj_city_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void sale_prices_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.Sale_Prices_Zip.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.Sale_Prices_City.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("sale_prices_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void mortgage_rate_jumbo_fixed_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        List<TimeValueItemResult> result = ZillowService.get_loan_interest(ZillowTypeEnum.MortgageRateJumboFixed.getKey(), year);
        model.addAttribute("mortgage_rate_jumbo_fixed_result", result);
    }

    @Override
    public void mortgage_rate_conventional_fixed_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        List<TimeValueItemResult> result = ZillowService.get_loan_interest(ZillowTypeEnum.MortgageRateConventionalFixed.getKey(), year);
        model.addAttribute("mortgage_rate_conventional_fixed_result", result);
    }

    @Override
    public void inventory_measure_tiers_metro_public_count_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        InventoryResult result = ZillowService.inventory("count", zipCode.getZip());
        model.addAttribute("inventory_measure_tiers_metro_public_count_result", result);
    }

    @Override
    public void inventory_measure_tiers_metro_public_pct_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        InventoryResult result = ZillowService.inventory("pct", zipCode.getZip());
        model.addAttribute("inventory_measure_tiers_metro_public_pct_result", result);
    }

    @Override
    public void negative_equity_metro_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            MetroNETiersResult result = ZillowService.get_Metro_NETiers(ZillowTypeEnum.Metro_NETiers.getKey(), zipCode.getZip());
            model.addAttribute("negative_equity_metro_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void negative_equity_city_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = ZillowService.get_NegativeEquity_Public(ZillowTypeEnum.NegativeEquity.getKey(), zipCode.getZip(), year);
            model.addAttribute("negative_equity_city_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void monthly_turnover_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.MonthlyTurnover_Zip.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.MonthlyTurnover_City.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY_COUNTY);
            }

            model.addAttribute("monthly_turnover_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void foreclosures_per_10k_homes_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = null;

            if (dataType.equalsIgnoreCase("zip")) {
                result = ZillowService.getTimeSeries(ZillowTypeEnum.ForeclosuresPer10Khomes_Zip.getKey(), zipCode.getZip(), year);
            } else if (dataType.equalsIgnoreCase("city")) {
                result = zilLowByCityService.getTimeSeriesByCity(ZillowTypeEnum.ForeclosuresPer10Khomes_City.getKey(), zipCode, year, ZilLowSearchTypeEnum.STATE_CITY);
            }

            model.addAttribute("foreclosures_per_10k_homes_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void affordability_income_result(Model model, ZipCode zipCode, String dataType, Integer year) {
        try {
            List<TimeValueItemResult> result = ZillowService.getTimeSeries(ZillowTypeEnum.Affordability_Income.getKey(), zipCode.getZip(), year);
            model.addAttribute("affordability_income_result", result);
        } catch (CustomException e) {
            e.printStackTrace();
        }
    }


}
